if(!debug)
var debug = 0;


document.onclick = function(e)
{
    if(topWindow && topWindow.onclick)
    {
        //topWindow.onclick(e);
        return 0;
    }
	// else
	//   this.stdOutDev.onclick();
};

document.onkeydown = function(e)
{
    if(topWindow && topWindow.onkeydown)
    {
        //topWindow.onclick(e);
        return 0;
    }
    //else
	//  this.stdOutDev.onkeydown();
};

document.onkeypress = function(e)
{
	// if(topWindow )//&& topWindow.onkeypress)
    //{
	//  topWindow.onclick(e);
	// return 0;
    //}
    //else
	//  this.stdOutDev.onkeypress();
};

document.onkeyup = function(e)
{
    if(topWindow && topWindow.onkeyup)
    {
        topWindow.onclick(e);
        return 0;
    }
	//else
	//      return;
};

document.onselect = function(e)
{
    return;
};

document.select = function(e)
{
    return;
};

document.onfocus = function(e)
{
    return;
};

document.onmousedown = function(e)
{
    if(topWindow && topWindow.onmousedown)
    {
        topWindow.onmousedown(e);
        return;
    }
    else
		return;
};



document.onmouseup = function(e)
{
    if(topWindow && topWindow.onmouseup)
    {
        topWindow.onmouseup(e);
        return;
    }
    else
		return;
	
};

document.onmousemove = function(e)
{
    if(topWindow && topWindow.onmousemove)
        topWindow.onmousemove(e);
};

document.onkeydown = function(e)
{
    if(topWindow && topWindow.onmousemove)
        topWindow.onmousemove(e);
};

var stdOutDev = document.createElement('div');
this.stdOutDev.id = "stdOut" ;

//default stdio console style
this.stdOutDev.style.position = "absolute"; 
this.stdOutDev.style.overflow = "hidden";   
this.stdOutDev.style.left = 10;
this.stdOutDev.style.top = 10;
this.stdOutDev.style.width = 780;
this.stdOutDev.style.height = 780;    
this.stdOutDev.style.color = "white";
this.stdOutDev.style.backgroundColor = "000000";
if(debug)
this.stdOutDev.style.visibility= "visible";
if(!debug)
this.stdOutDev.style.visibility= "hidden";    
this.stdOutDev.style.border = "inset red 4px";
this.stdOutDev.style.borderColor = "black" ;    
this.stdOutDev.style.borderWidth = "1px 1px";  
stdOutDev.innerHTML = "---init<Br>";
//this.stdOutDev.onselect = selected();
//this.stdOutDev.onselectstart = selected();
stdOutDev.onclick = "selected()";
this.stdOutDev.onkeypress = "selected(event)";

topWindow = stdOutDev;

function printf(string,flags)
{
    stdOutDev.innerHTML = stdOutDev.innerHTML + "<br>" + string +"<br>";
};

function cls()
{
    stdOutDev.innerHTML = "";	
};
